package com.isscollage.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;
import com.isscollage.entity.Ticket;
import com.isscollage.search.TicketSearch;
import com.isscollage.service.TicketService;

@Controller
@RequestMapping("ticket")
public class TicketController {

	@Autowired
	private TicketService ticketService;
	
	@RequestMapping("searchTicketsByCon")
	public String searchTicketsByCon(Map<String,Object> map,TicketSearch search){
		if(search==null){
			search=new TicketSearch();
		}
		List<Ticket> list=ticketService.searchTicketsByCon(search);
		PageInfo<Ticket> page=new PageInfo<Ticket>(list,2);
		map.put("page", page);
		map.put("search", search);
		return "ticket/ticketList";
	}
	
	@RequestMapping("insert")
	@ResponseBody
	public boolean insert(Ticket ticket){
		boolean flag=ticketService.insert(ticket);
		return flag;
	}
	
	@RequestMapping("getTicketById")
	@ResponseBody
	public Ticket getTicketById(Integer ticketId){
		Ticket ticket=new Ticket();
		ticket = ticketService.getTicketById(ticketId);
		return ticket;
	}
	
	@RequestMapping("update")
	@ResponseBody
	public boolean update(Ticket ticket){
		boolean flag=ticketService.update(ticket);
		return flag;
	}
	
	@RequestMapping("deleteAll")
	@ResponseBody
	public boolean deleteAll(@RequestBody Integer ids[]){
		boolean flag=ticketService.deleteAll(ids);
		return flag;
	}
}
